package com.skyline2yc.databus.controller;

import com.skyline2yc.databus.entity.DataSource;
import com.skyline2yc.databus.service.DataSourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/datasource")
public class DataSourceController {

    @Autowired
    private DataSourceService dataSourceService;


    /**
     * 获取所有数据源的名称
     */
    @GetMapping("/select")
    public List<String> selectAll() {
        List<String> result = dataSourceService.selectAll();
        return result;
    }


    /**
     * 根据数据源名称获取所有数据库实例名
     */
    @PostMapping("/query")
    public List<String> queryByName(@RequestParam("beanName") String beanName) {
        List<String> result = dataSourceService.queryByName(beanName);
        return result;
    }
}
